﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for NhaPhanPhoiDAO
/// </summary>
public class NhaPhanPhoiDAO:AbstractDAO
{
	public NhaPhanPhoiDAO(String strPath)
        : base(strPath)
    {

    }
    ~NhaPhanPhoiDAO()
    {
        base.Dispose();
    }

    public DataSet SelectNhaPhanPhoiAll()
    {
        DataSet ds;
        try
        {
            ds = new DataSet();
            base.sql = "usp_SelectNhaPhanPhoiAll";
            base.FillDataSet(ref ds, "SelectNhaPhanPhoiAll");
            return ds;
        }
        catch (System.Exception e)
        {
            throw new Exception(e.Message, e.InnerException);
        }
        finally
        {
            base.CleanUpObject();
        }
    }

    public Boolean InsertNhaPhanPhoi(NhaPhanPhoiDTO npp)
    {
        try
        {
            base.sql = "usp_InsertNhaPhanPhoi";
            base.InitializeCommand();

            base.AddParameter("@TenNhaPhanPhoi",
            SqlDbType.NVarChar, 100, npp.TenNPP);

            return ExecuteStoredProcedure();
        }
        catch (System.Exception ExceptionErr)
        {
            throw new Exception(ExceptionErr.Message, ExceptionErr.InnerException);

        }
    }

    public Boolean UpdateNhaPhanPhoi(NhaPhanPhoiDTO npp)
    {
        try
        {
            base.sql = "usp_UpdateNhaPhanPhoi";
            base.InitializeCommand();

            base.AddParameter("@id",
            SqlDbType.Int, 10, npp.Id);

            base.AddParameter("@TenNhaPhanPhoi",
            SqlDbType.NVarChar, 100, npp.TenNPP);

            return ExecuteStoredProcedure();
        }
        catch (System.Exception ExceptionErr)
        {
            return false;

        }
    }

    public Boolean DeleteNhaPhanPhoi(int id)
    {
        try
        {
            base.sql = "usp_DeleteNhaPhanPhoi";
            base.InitializeCommand();

            base.AddParameter("@id",
            SqlDbType.Int, 10, id);

            return ExecuteStoredProcedure();
        }
        catch (System.Exception ExceptionErr)
        {
            throw new System.Exception(ExceptionErr.Message,
            ExceptionErr.InnerException);
        }
    }
}
